﻿class eco.Vine extends MovieClip
{
    var lineStyle, originalThickness, onEnterFrame, lineTo, _y, _x, manager, attachMovie, _alpha, removeMovieClip;
    function Vine()
    {
        super();
        this.lineStyle(thickness, 26112 + (eco.Vine.MAX_THICKNESS - thickness) * 10 * 256, 100);
        originalThickness = thickness;
        onEnterFrame = doEnterFrame;
    } 
    function doEnterFrame()
    {
        var _loc3 = eco.Vine.MAX_THICKNESS - thickness + 1;
        angle = angle + 1.745329E-002 * (random(_loc3 * 30) - _loc3 * 15);
        var _loc4 = random(7) + _loc3 + 2;
        x = x + _loc4 * Math.cos(angle);
        y = y + _loc4 * Math.sin(angle);
        this.lineTo(x, y);
        if (thickness > 1 && random(thickness == eco.Vine.MAX_THICKNESS ? (12) : (16 * thickness)) == 1)
        {
            manager.createVein(thickness - 1 - random(thickness - 1), _x + x, _y + y, angle);
        } 
        if (thickness < eco.Vine.MAX_THICKNESS && count > random(22) * thickness)
        {
            count = 0;
            this.lineStyle(--thickness, 30464 + _loc3 * 10 * 256, 100);
            if (thickness == 0)
            {
                count = 130 + originalThickness * 30;
                onEnterFrame = fadeDown;
            } 
        }
        else
        {
            ++count;
        } 
        if (thickness == eco.Vine.MAX_THICKNESS)
        {
            if (count == 10)
            {
                var _loc6 = _root.nextDepth = ++_root.nextDepth % 1000;
                manager.createVein(thickness, _x + x, _y + y, angle);
                count = 440;
                onEnterFrame = fadeDown;
            } 
        }
        else if (leafDelay <= 0 && random(_loc3 * 2) < 4)
        {
            ++leafCount;
            leafDelay = 2 + random(4);
            this.attachMovie("eco.Vine:leaf", "l" + leafCount, leafCount, {_x: x, _y: y, _rotation: random(2) * -90 + angle / 3.141593E+000 * 180 + 160 - random(60), _xscale: random(60) + 70, _yscale: random(60) + 70});
        }
        else
        {
            --leafDelay;
        } 
    } 
    function fadeDown()
    {
        count = count - 2;
        _alpha = Math.min(_alpha, count);
        if (count <= 0)
        {
            delete this.onEnterFrame;
            this.removeMovieClip();
        } 
    } 
    static var MAX_THICKNESS = 6;
    var x = 0;
    var y = 0;
    var angle = 0;
    var thickness = eco.Vine.MAX_THICKNESS;
    var count = 0;
    var leafCount = 0;
    var leafDelay = 5;
} 
